import tkinter as tk
from tkinter.constants import HORIZONTAL, X
#2021-06-22 10:24 by 炸天帮成员
class create_new_frame():
    def __init__(self,root_id):
        self.window_0 = root_id
        self.create_entry_with_scroll()

    def create_entry_with_scroll(self):
        self.frame = tk.Frame(self.window_0)
        self.frame.pack()

        self.entry_label = tk.Label(self.frame,text="请输入：")
        self.entry_label.pack()
        self.entry_scroll = tk.Scrollbar(self.frame,orient = HORIZONTAL)
        self.entry = tk.Entry(self.frame,width=400,xscrollcommand=self.entry_scroll.set)
        self.entry.pack()
        self.entry_scroll.pack(fill=X)
        self.entry_scroll.config(command = self.entry.xview)
        self.entry_binding()

    def entry_binding(self):
        def getValueFromEntry(self):
            print("frame_in_window_0.entry中的值为 = ",frame_in_window_0.entry.get())
        self.entry.bind('<Return>',getValueFromEntry)


if __name__ == "__main__" :
    root_0 = tk.Tk()
    root_0.geometry('400x400')
    frame_in_window_0 = create_new_frame(root_0)
    root_0.mainloop()